package com.zq.assistant.func.log;

import android.util.Log;

import com.zq.assistant.BuildConfig;

/** 封装的打印信息类
 * Created by zhangqiang on 17-6-16.
 */

public class Logger {

    private static final Logger instance = new Logger();
    private boolean DEBUG;

    public Logger() {

        try {
            Class buildConfigClass = Class.forName("com.zq.assistant.BuildConfig");
            DEBUG = buildConfigClass.getField("DEBUG").getBoolean(null);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (NoSuchFieldException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
    }

    public static Logger get() {
        return instance;
    }

    public void e(String tag,String info){

        if(!DEBUG){
            return;
        }
        Log.e(tag,info);
    }

    public void i(String tag,String info){

        if(!DEBUG){
            return;
        }
        Log.i(tag,info);
    }

    public void d(String tag,String info){

        if(!DEBUG){
            return;
        }
        Log.d(tag,info);
    }

}
